const useImpCpts = defineStore("impCpts-winRes", () => {
  const curCpt = ref("Pending");
  const cpts = shallowRef<Record<string, Component>>({});
  const modules: Record<string, { default: Component }> = import.meta.glob(
    ["./*.vue", "!./index.vue", "!./WinIt4.vue", "!./WinIt5.vue"],
    { eager: true }
  );
  Object.entries(modules).forEach(([key, module]) => {
    const fileName = key.replace(/^\.\/(.*)\.vue$/, "$1");
    unref(cpts)[fileName] = module.default;
  });
  const setCurCpt = (name: string) => {
    curCpt.value = name;
  };
  const toggleCpt = (cptName: string) => {
    if (unref(cpts)[cptName]) {
      setCurCpt(cptName);
    } else {
      console.warn(`组件 ${cptName} 不存在`);
    }
  };
  return { curCpt, cpts, toggleCpt };
});
export const useImpCptsRefs = () => storeToRefs(useImpCpts());
export default useImpCpts;
